package com.hsylient.javase.chapter05;

import lombok.SneakyThrows;
import org.junit.Test;

import java.io.FileInputStream;
import java.io.InputStreamReader;

/**
 * 转换流 -> 字节流转换为字符流
 */
public class I_MyInputStreamReader {

    @Test
    @SneakyThrows
    public void testInputStreamReader() {
        FileInputStream fileInputStream = new FileInputStream("D:\\IdeaProjects\\logger\\log\\xx.txt");
        InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream);
        char[] chars = new char[10];
        int readLen;
        while ((readLen = inputStreamReader.read(chars)) != -1) {
            System.out.print(new String(chars, 0, readLen));
        }
        fileInputStream.close();
    }
}
